var createCluster = (() => {
    return async function (moduleArg = {}) {
        var moduleRtn;
        var Module = moduleArg;
        var readyPromiseResolve, readyPromiseReject;
        var readyPromise = new Promise((resolve, reject) => {
            readyPromiseResolve = resolve;
            readyPromiseReject = reject;
        });
        var ENVIRONMENT_IS_WEB = true;
        var ENVIRONMENT_IS_WORKER = false;
        var moduleOverrides = { ...Module };
        var arguments_ = [];
        var thisProgram = './this.program';
        var scriptDirectory = '';

        function locateFile(path) {
            if (Module['locateFile']) {
                return Module['locateFile'](path, scriptDirectory);
            }
            return scriptDirectory + path;
        }
        var readAsync, readBinary;
        if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
            if (ENVIRONMENT_IS_WORKER) {
                scriptDirectory = self.location.href;
            } else if (typeof document != 'undefined' && document.currentScript) {
                scriptDirectory = document.currentScript.src;
            }
            if (scriptDirectory.startsWith('blob:')) {
                scriptDirectory = '';
            } else {
                scriptDirectory = scriptDirectory.slice(
                    0,
                    scriptDirectory.replace(/[?#].*/, '').lastIndexOf('/') + 1
                );
            }
            {
                readAsync = async url => {
                    var response = await fetch(url, {
                        credentials: 'same-origin',
                    });
                    if (response.ok) {
                        return response.arrayBuffer();
                    }
                    throw new Error(response.status + ' : ' + response.url);
                };
            }
        } else {
        }
        var out = Module['print'] || console.log.bind(console);
        var err = Module['printErr'] || console.error.bind(console);
        Object.assign(Module, moduleOverrides);
        moduleOverrides = null;
        if (Module['arguments']) arguments_ = Module['arguments'];
        if (Module['thisProgram']) thisProgram = Module['thisProgram'];
        var wasmBinary = Module['wasmBinary'];
        var wasmMemory;
        var ABORT = false;
        var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAP64, HEAPU64, HEAPF64;
        var runtimeInitialized = false;

        function updateMemoryViews() {
            var b = wasmMemory.buffer;
            Module['HEAP8'] = HEAP8 = new Int8Array(b);
            Module['HEAP16'] = HEAP16 = new Int16Array(b);
            Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
            Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
            Module['HEAP32'] = HEAP32 = new Int32Array(b);
            Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
            Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
            Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
            Module['HEAP64'] = HEAP64 = new BigInt64Array(b);
            Module['HEAPU64'] = HEAPU64 = new BigUint64Array(b);
        }

        function preRun() {
            if (Module['preRun']) {
                if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
                while (Module['preRun'].length) {
                    addOnPreRun(Module['preRun'].shift());
                }
            }
            callRuntimeCallbacks(onPreRuns);
        }

        function initRuntime() {
            runtimeInitialized = true;
            wasmExports['d']();
        }

        function postRun() {
            if (Module['postRun']) {
                if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
                while (Module['postRun'].length) {
                    addOnPostRun(Module['postRun'].shift());
                }
            }
            callRuntimeCallbacks(onPostRuns);
        }
        var runDependencies = 0;
        var dependenciesFulfilled = null;

        function addRunDependency(id) {
            runDependencies++;
            Module['monitorRunDependencies']?.(runDependencies);
        }

        function removeRunDependency(id) {
            runDependencies--;
            Module['monitorRunDependencies']?.(runDependencies);
            if (runDependencies == 0) {
                if (dependenciesFulfilled) {
                    var callback = dependenciesFulfilled;
                    dependenciesFulfilled = null;
                    callback();
                }
            }
        }

        function abort(what) {
            Module['onAbort']?.(what);
            what = 'Aborted(' + what + ')';
            err(what);
            ABORT = true;
            what += '. Build with -sASSERTIONS for more info.';
            var e = new WebAssembly.RuntimeError(what);
            readyPromiseReject(e);
            throw e;
        }
        var wasmBinaryFile;

        function findWasmBinary() {
            if (Module['locateFile']) {
                return locateFile('cluster-module.wasm');
            }
            return new URL(window.clusterUrl + 'cluster-module.wasm', window.clusterUrl).href;
        }

        function getBinarySync(file) {
            if (file == wasmBinaryFile && wasmBinary) {
                return new Uint8Array(wasmBinary);
            }
            if (readBinary) {
                return readBinary(file);
            }
            throw 'both async and sync fetching of the wasm failed';
        }
        async function getWasmBinary(binaryFile) {
            if (!wasmBinary) {
                try {
                    var response = await readAsync(binaryFile);
                    return new Uint8Array(response);
                } catch {}
            }
            return getBinarySync(binaryFile);
        }
        async function instantiateArrayBuffer(binaryFile, imports) {
            try {
                var binary = await getWasmBinary(binaryFile);
                var instance = await WebAssembly.instantiate(binary, imports);
                return instance;
            } catch (reason) {
                err(`failed to asynchronously prepare wasm: ${reason}`);
                abort(reason);
            }
        }
        async function instantiateAsync(binary, binaryFile, imports) {
            if (!binary && typeof WebAssembly.instantiateStreaming == 'function') {
                try {
                    var response = fetch(binaryFile, {
                        credentials: 'same-origin',
                    });
                    var instantiationResult = await WebAssembly.instantiateStreaming(
                        response,
                        imports
                    );
                    return instantiationResult;
                } catch (reason) {
                    err(`wasm streaming compile failed: ${reason}`);
                    err('falling back to ArrayBuffer instantiation');
                }
            }
            return instantiateArrayBuffer(binaryFile, imports);
        }

        function getWasmImports() {
            return {
                a: wasmImports,
            };
        }
        async function createWasm() {
            function receiveInstance(instance, module) {
                wasmExports = instance.exports;
                wasmMemory = wasmExports['c'];
                updateMemoryViews();
                removeRunDependency('wasm-instantiate');
                return wasmExports;
            }
            addRunDependency('wasm-instantiate');

            function receiveInstantiationResult(result) {
                return receiveInstance(result['instance']);
            }
            var info = getWasmImports();
            if (Module['instantiateWasm']) {
                return new Promise((resolve, reject) => {
                    Module['instantiateWasm'](info, (mod, inst) => {
                        receiveInstance(mod, inst);
                        resolve(mod.exports);
                    });
                });
            }
            wasmBinaryFile ??= findWasmBinary();
            try {
                var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
                var exports = receiveInstantiationResult(result);
                return exports;
            } catch (e) {
                readyPromiseReject(e);
                return Promise.reject(e);
            }
        }
        class ExitStatus {
            name = 'ExitStatus';
            constructor(status) {
                this.message = `Program terminated with exit(${status})`;
                this.status = status;
            }
        }
        var callRuntimeCallbacks = callbacks => {
            while (callbacks.length > 0) {
                callbacks.shift()(Module);
            }
        };
        var onPostRuns = [];
        var addOnPostRun = cb => onPostRuns.unshift(cb);
        var onPreRuns = [];
        var addOnPreRun = cb => onPreRuns.unshift(cb);
        var noExitRuntime = Module['noExitRuntime'] || true;
        var stackRestore = val => __emscripten_stack_restore(val);
        var stackSave = () => _emscripten_stack_get_current();
        var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder() : undefined;
        var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => {
            var endIdx = idx + maxBytesToRead;
            var endPtr = idx;
            while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
            if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
                return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
            }
            var str = '';
            while (idx < endPtr) {
                var u0 = heapOrArray[idx++];
                if (!(u0 & 128)) {
                    str += String.fromCharCode(u0);
                    continue;
                }
                var u1 = heapOrArray[idx++] & 63;
                if ((u0 & 224) == 192) {
                    str += String.fromCharCode(((u0 & 31) << 6) | u1);
                    continue;
                }
                var u2 = heapOrArray[idx++] & 63;
                if ((u0 & 240) == 224) {
                    u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
                } else {
                    u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
                }
                if (u0 < 65536) {
                    str += String.fromCharCode(u0);
                } else {
                    var ch = u0 - 65536;
                    str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023));
                }
            }
            return str;
        };
        var UTF8ToString = (ptr, maxBytesToRead) =>
            ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
        var ___assert_fail = (condition, filename, line, func) =>
            abort(
                `Assertion failed: ${UTF8ToString(condition)}, at: ` +
                    [
                        filename ? UTF8ToString(filename) : 'unknown filename',
                        line,
                        func ? UTF8ToString(func) : 'unknown function',
                    ]
            );
        var abortOnCannotGrowMemory = requestedSize => {
            abort('OOM');
        };
        var _emscripten_resize_heap = requestedSize => {
            var oldSize = HEAPU8.length;
            requestedSize >>>= 0;
            abortOnCannotGrowMemory(requestedSize);
        };
        var getCFunc = ident => {
            var func = Module['_' + ident];
            return func;
        };
        var writeArrayToMemory = (array, buffer) => {
            HEAP8.set(array, buffer);
        };
        var lengthBytesUTF8 = str => {
            var len = 0;
            for (var i = 0; i < str.length; ++i) {
                var c = str.charCodeAt(i);
                if (c <= 127) {
                    len++;
                } else if (c <= 2047) {
                    len += 2;
                } else if (c >= 55296 && c <= 57343) {
                    len += 4;
                    ++i;
                } else {
                    len += 3;
                }
            }
            return len;
        };
        var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
            if (!(maxBytesToWrite > 0)) return 0;
            var startIdx = outIdx;
            var endIdx = outIdx + maxBytesToWrite - 1;
            for (var i = 0; i < str.length; ++i) {
                var u = str.charCodeAt(i);
                if (u >= 55296 && u <= 57343) {
                    var u1 = str.charCodeAt(++i);
                    u = (65536 + ((u & 1023) << 10)) | (u1 & 1023);
                }
                if (u <= 127) {
                    if (outIdx >= endIdx) break;
                    heap[outIdx++] = u;
                } else if (u <= 2047) {
                    if (outIdx + 1 >= endIdx) break;
                    heap[outIdx++] = 192 | (u >> 6);
                    heap[outIdx++] = 128 | (u & 63);
                } else if (u <= 65535) {
                    if (outIdx + 2 >= endIdx) break;
                    heap[outIdx++] = 224 | (u >> 12);
                    heap[outIdx++] = 128 | ((u >> 6) & 63);
                    heap[outIdx++] = 128 | (u & 63);
                } else {
                    if (outIdx + 3 >= endIdx) break;
                    heap[outIdx++] = 240 | (u >> 18);
                    heap[outIdx++] = 128 | ((u >> 12) & 63);
                    heap[outIdx++] = 128 | ((u >> 6) & 63);
                    heap[outIdx++] = 128 | (u & 63);
                }
            }
            heap[outIdx] = 0;
            return outIdx - startIdx;
        };
        var stringToUTF8 = (str, outPtr, maxBytesToWrite) =>
            stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
        var stackAlloc = sz => __emscripten_stack_alloc(sz);
        var stringToUTF8OnStack = str => {
            var size = lengthBytesUTF8(str) + 1;
            var ret = stackAlloc(size);
            stringToUTF8(str, ret, size);
            return ret;
        };
        var ccall = (ident, returnType, argTypes, args, opts) => {
            var toC = {
                string: str => {
                    var ret = 0;
                    if (str !== null && str !== undefined && str !== 0) {
                        ret = stringToUTF8OnStack(str);
                    }
                    return ret;
                },
                array: arr => {
                    var ret = stackAlloc(arr.length);
                    writeArrayToMemory(arr, ret);
                    return ret;
                },
            };

            function convertReturnValue(ret) {
                if (returnType === 'string') {
                    return UTF8ToString(ret);
                }
                if (returnType === 'boolean') return Boolean(ret);
                return ret;
            }
            var func = getCFunc(ident);
            var cArgs = [];
            var stack = 0;
            if (args) {
                for (var i = 0; i < args.length; i++) {
                    var converter = toC[argTypes[i]];
                    if (converter) {
                        if (stack === 0) stack = stackSave();
                        cArgs[i] = converter(args[i]);
                    } else {
                        cArgs[i] = args[i];
                    }
                }
            }
            var ret = func(...cArgs);
            function onDone(ret) {
                if (stack !== 0) stackRestore(stack);
                return convertReturnValue(ret);
            }
            ret = onDone(ret);
            return ret;
        };
        var cwrap = (ident, returnType, argTypes, opts) => {
            var numericArgs =
                !argTypes || argTypes.every(type => type === 'number' || type === 'boolean');
            var numericRet = returnType !== 'string';
            if (numericRet && numericArgs && !opts) {
                return getCFunc(ident);
            }
            return (...args) => ccall(ident, returnType, argTypes, args, opts);
        };
        var wasmImports = {
            a: ___assert_fail,
            b: _emscripten_resize_heap,
        };
        var wasmExports = await createWasm();
        var ___wasm_call_ctors = wasmExports['d'];
        var _free = (Module['_free'] = wasmExports['e']);
        var _malloc = (Module['_malloc'] = wasmExports['f']);
        var _calculate_cluster = (Module['_calculate_cluster'] = wasmExports['h']);
        var __emscripten_stack_restore = wasmExports['i'];
        var __emscripten_stack_alloc = wasmExports['j'];
        var _emscripten_stack_get_current = wasmExports['k'];
        Module['ccall'] = ccall;
        Module['cwrap'] = cwrap;

        function run() {
            if (runDependencies > 0) {
                dependenciesFulfilled = run;
                return;
            }
            preRun();
            if (runDependencies > 0) {
                dependenciesFulfilled = run;
                return;
            }

            function doRun() {
                Module['calledRun'] = true;
                if (ABORT) return;
                initRuntime();
                readyPromiseResolve(Module);
                Module['onRuntimeInitialized']?.();
                postRun();
            }
            if (Module['setStatus']) {
                Module['setStatus']('Running...');
                setTimeout(() => {
                    setTimeout(() => Module['setStatus'](''), 1);
                    doRun();
                }, 1);
            } else {
                doRun();
            }
        }
        if (Module['preInit']) {
            if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
            while (Module['preInit'].length > 0) {
                Module['preInit'].pop()();
            }
        }
        run();
        moduleRtn = readyPromise;
        return moduleRtn;
    };
})();
